# -*- coding: utf-8 -*-

import gurobipy as gp
from gurobipy import *

# tuple_dict = {('a', 1): 'a_one', ('b', 2): 'b_two', ('c', 3): 'c_three'}
# print(tuple_dict)  # {('a', 1): 'a_one', ('b', 2): 'b_two', ('c', 3): 'c_three'}
# print(tuple_dict['b', 2])  # b_two
# print(tuple_dict[('b', 2)])  # b_two

# m = Model()
# x = m.addVars(2, 3)
# print(x)

# keys, dict1, dict2 = gp.multidict( {
# 'key1': [1, 2],
# 'key2': [1, 3],
# 'key3': [1, 4] } )

# print(keys)
# print(type(keys))
# print(dict1)
# print(type(dict1))
# print(dict2)
# print(type(dict2))

# print(type({'key1': 1, 'key2': 1, 'key3': 1}))


# nutritionValues = ({
#     ('hamburger', 'calories'): 410,
#     ('hamburger', 'protein'): 24,
#     ('hamburger', 'fat'): 26,
#     ('hamburger', 'sodium'): 730,
#     ('chicken', 'calories'): 420,
#     ('chicken', 'protein'): 32, 
#     ('chicken', 'fat'): 10,
#     ('chicken', 'sodium'): 1190,
#     ('hotdog', 'calories'): 560,
#     ('hotdog', 'protein'): 20,
#     ('hotdog', 'fat'): 32,
#     ('hotdog', 'sodium'): 1800})
    
# m = Model()
# x = m.addVars(2, 3)
# print(x)

# print(type(x))
# expr = x.sum()
# print(expr)
# expr1 = x.sum(1, '*')
# print("--------------------------------------------------")
# print(expr1)

# cost = {
#     ('W1', 'C1'): 2,
#     ('W1', 'C2'): 4,
#     ('W2', 'C1'): 3,
#     ('W2', 'C2'): 1,
# }



# Cities= [('A','B','C','D'), ('A','C','D','E'), ('B','C','B','C'),('B','D','B','C'),('C','A','B','C')]
# Routes = tuplelist(Cities)
# print(Routes.select('A','*'))
# print(Routes.select('*','C', 'B'))





# # 创建一个新的模型
# m = gp.Model()

# # 添加变量，创建一个tupledict
# x = m.addVars([(1,2), (1,3), (2,3)], name="x")
# print(type(x))
# print(x)
# coeff = { (1,2): 2.0, (1,3): 2.1, (2,3): 3.3 }

# # 使用prod方法创建线性表达式
# expr = x.prod(coeff)

# # 输出线性表达式
# print(expr)  # 输出: 2.0 x[1,2] + 2.1 x[1,3] + 3.3 x[2,3]

# # 也可以使用模式匹配来创建部分线性表达式
# expr_partial = x.prod(coeff, '*', 3)
# print(expr_partial)  # 输出: 2.1 x[1,3] + 3.3 x[2,3]


# m = gp.Model()
# x = m.addVars(2, 2)
# coef = { (0, 0) : 0.3, (0, 1) : 0.5, (1, 0) : 0.1, (1, 1) : 0.7 }
# print(type(coef))
# expr = x.prod(coef)
# print(expr)



# skill, time = multidict({
#     'coding' : 4,
#     'business' : 4,
#     'test' : 1
# })

# m = gp.Model()
# x = m.addVars(skill, name = 'x')
# expr = x.prod(time)
# print(expr)
# m.setObjective(expr, GRB.MINIMIZE)


# categories, minNutrition, maxNutrition = multidict({
#     'calories': [1800, GRB.INFINITY],
#     'protein': [91, GRB.INFINITY],
#     'fat': [0, GRB.INFINITY],
#     'sodium': [0, GRB.INFINITY]})

# print(type(categories.select('fat')))

# print(minNutrition[categories.select('protein')[0]])


